package com.atguigu;

import com.atguigu.bean.Boss;
import com.atguigu.bean.Car;
import com.atguigu.bean.Color;
import com.atguigu.config.MaainConfigOfAutowired;
import com.atguigu.dao.BookDao;
import com.atguigu.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Honglixi
 * @create 2021-03-27 9:23
 */
public class IOCTest_Autowired {
    @Test
    public void test01(){
        //1.创建ioc容器
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MaainConfigOfAutowired.class);
        BookService bean = applicationContext.getBean(BookService.class);
//        bean.print();
        System.out.println(bean);
//        BookDao bean1 = applicationContext.getBean(BookDao.class);
//        System.out.println(bean1);
        Boss boss = applicationContext.getBean(Boss.class);
        System.out.println(boss);
        Car car = applicationContext.getBean(Car.class);
        System.out.println(car);
        Color color = applicationContext.getBean(Color.class);
        System.out.println(color);

        applicationContext.close();

    }
}
